<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Constructor</title>
</head>
<body>
    <script>
        // 构造函数
        function Create_user(name, age, sex, money) {
            this.name = name;
            this.age = age;
            this.sex = sex;
            this.money = money;
            this.add = 'hyl'
            // this.intro = function() {
            //     // console.log('1234'); 重复代码尽量不要重复执行
            //     var str = `name:${name}, age: ${age}, 
            //     sex:${sex}, money: ${money}<br />`;
            //     var oDiv = document.querySelector('#app');
            //     document.write(str)
            // };
        }
        Create_user.prototype.add = 'yjl';
        Create_user.prototype.job = 'front-end'
        // 原型  每一个构造函数都会有prototype这个对象，对象中的属性和方法会被所以的实例继承
        Create_user.prototype.show = function() {
            var str = `name:${this.name}, age: ${this.age}, 
                sex:${this.sex}, money: ${this.money}, add: ${this.add}, job:${this.job}<br />`;
                var oDiv = document.querySelector('#app');
                document.write(str)
        }
        // 创建一个Create_user的实例   实例化
        var deren = new Create_user('的人', 18, '男', 9999);
        var pangX = new Create_user('px', 38, '男', 99999);
        deren.show();
        pangX.show();
        console.log(deren.age);
        console.log(deren instanceof Create_user);
        console.log(pangX.constructor);
    </script>
</body>
</html>